package com.ng.biz.service.impl;

import java.util.Date;

import org.springframework.stereotype.Service;
import com.ng.biz.model.domain.DataLog;
import com.ng.biz.model.domain.DataLogInput;
import com.ng.biz.model.domain.DataLogOutput;
import com.ng.biz.service.IDataLog;
import com.ng.common.util.UuidUtil;

@Service
public class DataLogImpl implements IDataLog{

	@Override
	public DataLog createDataLog(String taskId,String taskName,String taskType) {
		DataLog dataLog=new DataLog();
		dataLog.setId(UuidUtil.getUUID());
		dataLog.setTaskId(taskId);
		dataLog.setTitle(taskName);
		dataLog.setType(taskType);
		dataLog.setStartTime(new Date(System.currentTimeMillis()));
		dataLog.save();
		return dataLog;
	}

	@Override
	public DataLog buildUpdateDataLog(String dataLogId) {
		DataLog dataLog=new DataLog();
		dataLog.setId(dataLogId);
		return dataLog;
	}

	@Override
	public DataLogInput createDataLogInput(String logDataId, int cur,int pageSize) {
		DataLogInput dataLogInput=new DataLogInput();
		dataLogInput.setId(UuidUtil.getUUID());
		dataLogInput.setLogId(logDataId);
		dataLogInput.setCur(cur);
		dataLogInput.setPageSize(pageSize);
		dataLogInput.setStartTime(new Date(System.currentTimeMillis()));
		dataLogInput.setStatus("0");
		dataLogInput.save();
		return dataLogInput;
	}
	
	@Override
	public DataLogInput buildUpdateDataLogInput(String dataLogInputId) {
		DataLogInput inputDataLog=new DataLogInput();
		inputDataLog.setId(dataLogInputId);
		return inputDataLog;
	}

	@Override
	public DataLogOutput createDataLogOutput(String dataLogId,String dataLogInputId,String type,int total) {
		DataLogOutput dataLogOutput=new DataLogOutput();
		dataLogOutput.setId(UuidUtil.getUUID());
		dataLogOutput.setDataLogId(dataLogId);
		dataLogOutput.setDataLogInputId(dataLogInputId);
		dataLogOutput.setType(type);
		dataLogOutput.setTotal(total);
		dataLogOutput.setStartTime(new Date(System.currentTimeMillis()));
		dataLogOutput.setStatus("0");
		dataLogOutput.save();
		return dataLogOutput;
	}

	@Override
	public DataLogOutput buildUpdateDataLogOutput(String dataLogInputId) {
		DataLogOutput dataLogOutput=new DataLogOutput();
		dataLogOutput.setId(dataLogInputId);
		return dataLogOutput;
	}
	

}
